import 'dart:ffi';

import 'package:dance_todo/main.dart';
import 'package:dance_todo/pages/page_home.dart';
import 'package:dance_todo/res/res_colors.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:lottie/lottie.dart';

class SplashPage extends StatefulWidget {
  const SplashPage({Key? key}) : super(key: key);

  @override
  State<SplashPage> createState() => _SplashPageState();
}

class _SplashPageState extends State<SplashPage> {
  @override
  void initState() {
    super.initState();
    waitLoadLottiesAndJump();
  }

  @override
  Widget build(BuildContext context) {
    return Material(
      color: Colors.black87,
      child: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Container(
              child: Text(
                'DanceTodo',
                style: TextStyle(
                  color: Color.fromARGB(255, 27, 248, 163),
                  fontSize: 70.0,
                ),
              ),
            ),
            Container(
              child: Text(
                'just do it',
                style: TextStyle(
                  color: ColorActiveRed,
                  fontSize: 50.0,
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

  void waitLoadLottiesAndJump() async {
    lottieLike = await AssetLottie('assets/lotties/lottie_like_2.json').load();
    lottieTrophy = await AssetLottie('assets/lotties/lottie_trophy.json').load();
    lottieCalender = await AssetLottie('assets/lotties/lottie_calender.json').load();
    lottieCreate = await AssetLottie('assets/lotties/lottie_create.json').load();
    lottieSchedule=await AssetLottie('assets/lotties/lottie_schedule.json').load();

    Future.delayed(Duration(seconds: 1),(){
      Get.to(()=>const HomePage());
    });
  }
}
